﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Layouts/List.Master" CodeBehind="DeliveredList.aspx.cs" Inherits="Bingosoft.WebApp.Modules.DeliveredManager.DeliveredList" %>
<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">
    <!-- title -->    
    <style type="text/css">
        .menu
        {
            width:53px;
            position: relative;
            height: 29px;
            display:inline;
            margin-top:5px;
        }
        .menu ul
        {
            display: none;
            position: absolute;
            top: 26px;
            right: 0px;
            background-color: #FFF;
            border: 1px solid #30A5FF;
            width: 125px;
            margin: 0;
            padding: 0;
            z-index: 10000;
            float: right;
        }
        .menu ul li
        {
            width: 100%;
            overflow: hidden;
            list-style-type: none;
            height: 18px;
            line-height: 18px;
            vertical-align: middle;
            cursor: pointer;
            text-align: left;
        }
        .menu ul li span
        {
            display: block;
            padding-left: 8px;
        }
        .menu ul li.line
        {
            height: 1px;
            line-height: 1px;
            border-top: 1px solid #AAA;
            width: 90%;
            margin: auto;
            text-align: center;
        }
    </style>
</asp:Content>

<asp:Content ID="idContent" ContentPlaceHolderID="Content" runat="Server">   
    <!-- 搜索框 -->
	<div class="search" style="margin-top:2px;">
        <web:search ID="GridSearch" GridViewId="SmartGridView1" runat="server">            
            <SearchConditionTemplate>                                       
                <table cellpadding="0" cellspacing="0" width="95%">
			        <tr>
                        <th>
                            开始日期：
                        </th>
                        <td>
                            <web:DatePicker ID="dpCreateDtStart" Name="beginTime" runat="server" DateTimeFormat="yyyy-MM-dd"
                                validator="required"></web:DatePicker>
                        </td>
                        <th>
                            结束日期：
                        </th>
                        <td>
                            <web:DatePicker ID="dpCreateDtEnd" Name="endTime" runat="server" DateTimeFormat="yyyy-MM-dd"
                                validator="required"></web:DatePicker>
                        </td> 
                        <th>
                            物资编号：
                        </th>
                        <td>
                            <asp:TextBox ID="txtMaterialsNo" name="MaterialsNo" CssClass="txtSelect" runat="server"></asp:TextBox>
                        </td>                                     
                    </tr>
                    <tr>
                        <th>
                            物资名称：
                        </th>
                        <td>
                            <asp:TextBox ID="txtMaterialsName" name="MaterialsName" CssClass="txtSelect" runat="server"></asp:TextBox>
                        </td>
                        <th>
                            物资规格（型号）：
                        </th>
                        <td>
                            <asp:TextBox ID="txtMaterialsModel" name="MaterialsModel" CssClass="txtSelect" runat="server"></asp:TextBox>
                        </td>
                        <th>
                            领料人：
                        </th>
                        <td>
                            <asp:TextBox ID="txtPickingor" name="Pickingor" CssClass="txtSelect" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>
                            班组：
                        </th>
                        <td>
                            <asp:TextBox ID="txtTeam" Name="Team" CssClass="txtSelect" runat="server"></asp:TextBox>
                        </td>
                        <th>
                            机车号：
                        </th>
                        <td>
                            <asp:TextBox ID="txtLocomotiveNo" Name="LocomotiveNo" CssClass="txtSelect" runat="server"></asp:TextBox>
                        </td>
                        <th>
                            机车修程：
                        </th>
                        <td>
                            <asp:TextBox ID="txtRepairProcess" Name="RepairProcess" CssClass="txtSelect" runat="server"></asp:TextBox>
                            <asp:TextBox ID="txtType" Visible="false" Name="Type" CssClass="txtSelect" runat="server"></asp:TextBox>
                        <asp:TextBox ID="txtOrgId" name="OrgId" CssClass="txtSelect" Visible="false" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </table>
            </SearchConditionTemplate>                      
        </web:search>        
    </div>

    <div class="datalist">
	    <!-- 标题头 -->
	    <h2 style="height:30px;">
				 <%= this.titleStr %>
	    </h2>
	    <!-- 工具栏 -->
	    <div class="toolbar"  style="height:30px;">
         <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButtonExport_Click">
                <span>
                    <img id="Img2" alt="" runat="server" src="~/Images/icon_excel.gif" style="border: 0px" />导出
                </span>
            </asp:LinkButton>
            <%if (this.Type == "1")
              { %>
            <asp:LinkButton runat="server" OnClientClick="return openEditor(1, 'Insert');" >
                <span>
                    <img alt="新购配件或材料出库" title="新购配件或材料出库" runat="server" id="img1" src="~/Images/icon_new.gif" style="border: 0px" />新建出库单
                </span>
            </asp:LinkButton> 
            <%} %>
             <%if (this.Type == "2")
              { %>
            <asp:LinkButton runat="server"
                OnClientClick="return openEditor(2, 'Insert');" >
                <span>
                    <img alt="维修良好的配件或材料出库" title="维修良好的配件或材料出库" runat="server" id="img0" src="~/Images/icon_new.gif" style="border: 0px" />新建出库单
                </span>
            </asp:LinkButton>
             <%} %>
            <%if (this.Type == "3")
              { %>
            <asp:LinkButton runat="server"
                OnClientClick="return openEditor(3, 'Insert');" >
                <span>
                    <img alt="委外修配件出库" title="委外修配件出库" runat="server" id="img3" src="~/Images/icon_new.gif" style="border: 0px" />新建出库单
                </span>
            </asp:LinkButton>
             <%} %>
             <%if (this.Type == "4")
              { %>
            <asp:LinkButton runat="server"
                OnClientClick="return openEditor(4, 'Insert');" >
                <span>
                    <img alt="下车配件或材料出库" title="下车配件或材料出库" runat="server" id="img4" src="~/Images/icon_new.gif" style="border: 0px" />新建出库单
                </span>
            </asp:LinkButton>
             <%} %>      
              <%-- <span id="lbtNew" class="menu" >
                <a href="javascript:void(0);">
                    <img src="../../Images/icon_new.gif" style="border: 0px" alt="新建" />出库 </a>
                <ul id="ulNew">
                    <li class="new1css" style="display:none">
                        <asp:LinkButton ID="btnNew1" runat="server" Style="display: block; float: left;z-index:999;
                            font-weight: normal;" Text="新购配件或材料出库" OnClientClick="return openEditor(1, 'Insert');" >
                        </asp:LinkButton>
                    </li>
                    <li class="new2css" style="display:none">
                        <asp:LinkButton ID="btnNew2" runat="server" Style="display: block; float: left;z-index:999;
                            font-weight: normal;" Text="维修良好的配件或材料出库" OnClientClick="return openEditor(2, 'Insert');">
                        </asp:LinkButton>
                    </li>
                    <li class="new3css" style="display:none">
                        <asp:LinkButton ID="btnNew3" runat="server" Style="display: block; float: left;z-index:999;
                            font-weight: normal;" Text="委外修配件出库" OnClientClick="return openEditor(3, 'Insert');" >
                        </asp:LinkButton>
                    </li>
                    <li class="new4css" style="display:none">
                        <asp:LinkButton ID="btnNew4" runat="server" Style="display: block; float: left;z-index:999;
                            font-weight: normal;" Text="下车配件或材料出库" OnClientClick="return openEditor(4, 'Insert');" >
                        </asp:LinkButton>
                    </li>
                </ul>--%>
            </span>   
	    </div>
	    <div class="datagrid"  style="clear:left;">    

            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" DataKeyNames="Id" DataSourceID="SmartDataSource1" PageSize="10" onrowdatabound="SmartGridView1_RowDataBound">
                <Columns>  
                    <asp:BoundField DataField="SubmitDt" HeaderText="出库时间" SortExpression="SubmitDt" ItemStyle-HorizontalAlign="left" />
                    <asp:BoundField DataField="MaterialsNo" HeaderText="物资编号" SortExpression="MaterialsNo" ItemStyle-HorizontalAlign="left" />
                    <asp:BoundField DataField="MaterialsName" HeaderText="物资名称"  ItemStyle-HorizontalAlign="center" SortExpression="MaterialsName"/>
                    <asp:BoundField DataField="MaterialsModel" HeaderText="物资规格（型号）" ItemStyle-HorizontalAlign="center" SortExpression="MaterialsModel"/>
                    <asp:BoundField DataField="DeliveredNum" HeaderText="出库数量" ItemStyle-HorizontalAlign="left" SortExpression="DeliveredNum" />
                    <asp:BoundField DataField="Unit" HeaderText="计量单位" ItemStyle-HorizontalAlign="left" SortExpression="Unit"/>
                    <asp:BoundField DataField="Price" HeaderText="单价" ItemStyle-HorizontalAlign="left" SortExpression="Price"/>
                    <asp:BoundField DataField="Amount" HeaderText="总金额" ItemStyle-HorizontalAlign="left" SortExpression="Amount" />
                    <asp:BoundField DataField="Pickingor" HeaderText="领料人" ItemStyle-HorizontalAlign="left"  SortExpression="Pickingor"/>
                    <asp:BoundField DataField="Team" HeaderText="班组" ItemStyle-HorizontalAlign="left" SortExpression="Team"/>
                    <asp:BoundField DataField="LocomotiveNo" HeaderText="机车号" ItemStyle-HorizontalAlign="left" SortExpression="LocomotiveNo" />
                   <%-- <asp:BoundField DataField="RepairProcess" HeaderText="机车修程" ItemStyle-HorizontalAlign="left" SortExpression="RepairProcess" />--%>
                        <web:DataDictonaryBoundField HeaderStyle-Width="100px" DataField="RepairProcess" DictionaryCode="RepairLevel"
                    HeaderText="机车修程" SortExpression="RepairProcess" />
                        <asp:BoundField DataField="Frame" HeaderText="架子" SortExpression="Frame" ItemStyle-HorizontalAlign="left" />
                    <asp:BoundField DataField="Level" HeaderText="层"  ItemStyle-HorizontalAlign="center" SortExpression="Level"/>
                    <asp:BoundField DataField="Sender" HeaderText="发料人" ItemStyle-HorizontalAlign="left" SortExpression="Sender" />
                     <web:DataDictonaryBoundField HeaderStyle-Width="100px" DataField="IsOld" DictionaryCode="YesOrNo"
                    HeaderText="是否交旧" SortExpression="IsOld" />
                    <asp:TemplateField HeaderText="操作">
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>
                                   <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnEdit" runat="server" ToolTip="编辑" _KeyId='<%#Eval("ID")%>'
                                            ImageUrl="~/images/com/dg_edit.gif" CausesValidation="False" OnClientClick="return openEditor(this, 'Edit');" OnClick="RefreshGrid">
                                        </asp:ImageButton>
                                    </td>
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton ID="ibtnDelete" runat="server" ToolTip="删除" ImageUrl="~/images/com/dg_del.gif" _KeyId='<%#Eval("ID")%>'
                                          OnClientClick="return confirm('您确认要删除吗?')" OnClick="DeleteDictionaryItem">
                                        </asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="Delivered.list" SelectCountCommand="Delivered.list.count"
            SelectCommandAutoPageWrap="true" DefaultSortExpression="ID desc">       
                        
            </web:SmartSqlDataSource>
        </div>
	</div>

    <script type="text/javascript">
        $(function () {
            //01.初始化类型
            var t = '<% =this.Type%>';
            $("input[id$='txtType']").val(t);
//            switch (t) {
//                case "1":
//                    $(".new1css").css("display", "inline");
//                    break;
//                case "2":
//                    $(".new2css").css("display", "inline");
//                    break;
//                case "3":
//                    $(".new3css").css("display", "inline");
//                    break;
//                case "4":
//                    $(".new4css").css("display", "inline");
//                    break;
//            }

//            //菜单控制
//            $(".menu").each(function () {
//                var current = $(this);
//                $(this).mouseenter(function () {
//                    window.setTimeout(function () { current.find("ul").slideDown(200); }, 200);
//                }).mouseleave(function () {
//                    window.setTimeout(function () { current.find("ul").slideUp(200); }, 200);
//                }).find("li").hover(function () {
//                    $(this).css("backgroundColor", "#56C0ED").css("color", "#FFF");
//                }, function () {
//                    $(this).css("backgroundColor", "#FFF").css("color", "#000");
//                });
//            });

        })
        function openEditor(type, action) {
            var url = "DeliveredEdit.aspx";
            //alert('<% =this.Type%>')
            // FormViewMode : Insert/Edit/ReadOnly
            var params = { FormViewMode: action }
            if (action == "Insert") {
                url = "DeliveredSelect.aspx";
                params.title = '新建' + '<% =this.titleStr%>';
                params.Type = type;
                params.r = 1;
            } else if (action == "Edit") {
                params.title = '编辑'+'<% =this.titleStr%>';
                params.d_ID = type.attributes["_KeyId"].value;
                params.Type = '<% =this.Type%>';
                params.r = 2;
            }

            var returnValue = showCenterModalDialog(buildUrl(url, params), 960, 350);
            if (returnValue == "true") {
                return true;
            }
            return false;
        }

    </script>
</asp:Content>
